﻿using HBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace hCommand.entity
{
    public class CyEqup : DelEntity, CacheData {

     
        public long userId {
            get; set;
        }
        public string code
        {
            get; set;
        }

        public string custom {
            get; set;
        }

        public int volCoil1 {
            get; set;
        }
        public int volCoil2 {
            get; set;
        }
        public int coilHz {
            get; set;
        }

        public int tmpFan {
            get; set;
        }
        public int nextQTime {
            get; set;
        }
        public int offlineTime {
            get; set;
        }
        public int canWork {
            get; set;
        }

        public DateTime useEndTime
        {//上次使用结束时间
            get; set;
        }

        public string alias
        {
            get; set;
        }

        public int tmpLimitFloor {
            get; set;
        }
        public int tmpLimitCeil {
            get; set;
        }
        public int vLimitFloor {
            get; set;
        }
        public int vLimitCeil {
            get; set;
        }
        public int iLimitFloor {
            get; set;
        }
        public int iLimitCeil {
            get; set;
        }
        private List<EqupPos> posList;
        public List<EqupPos> getPos() { 
        return posList;
        }
        public override string getId() {
            return code + "";
        }

        public override void keepOld(CacheData old)
        {
            lock (this) {
                CyEqup e = (CyEqup)old;
                
                posList = e.getPos();
            }
         
        }

        public void addPos(EqupPos pos) {
            if (useEndTime.Ticks < pos.time.Ticks) {
                return;
            }
            lock(this){
                if (posList == null)
                {
                    posList = new List<EqupPos>();

                }
            }

            for (int i = 0; i < posList.Count; i++) {
                if (posList[i]._id == pos._id) {
                    return;
                }
            }

            posList.Add(pos);
        }


    }
}
